﻿using Dora.Orm.Core.Domain.Entities;
using Dora.Services.AdminUser.Dto.QueryDto;
using Dora.Services.AdminUser.Dto.ViewDto;
using Dora.Services.AdminUser.Entities;
using Dora.Tools.Utility.Const;
using Surging.Core.Common;
using Surging.Core.CPlatform.Ioc;
using Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Attributes;
using Surging.Core.CPlatform.Support;
using Surging.Core.CPlatform.Support.Attributes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Dora.Services.AdminUser.IApplication
{
    /// <summary>
    /// 系统表服务接口
    /// </summary>
    [ServiceBundle("api/" + DoraModuleName.AdminUser + "/{Service}")]
    public interface ISystemInfoService : IServiceKey
    {

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-27", Director = "TTTan", Name = "创建")]
        Task<ResultDto<SystemInfoEntity>> Create(SystemInfoEntity entity);

        /// <summary>
        /// 根据Id获取一个实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-27", Director = "TTTan", Name = "根据Id获取一个实体对象")]
        Task<SystemInfoEntity> GetById(int id);
        
        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-27", Director = "TTTan", Name = "分页获取数据")]
        Task<PageDataList<SystemInfoListDto>> GetPageList(SystemInfoQueryDto input);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-27", Director = "TTTan", Name = "修改")]
        Task<ResultDto> Update(SystemInfoEntity entity);

        /// <summary>
        /// 根据IdList获取列表
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-27", Director = "TTTan", Name = "根据IdList获取列表")]
        Task<List<SystemInfoEntity>> GetList(List<int> idList);

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-04-27", Director = "TTTan", Name = "获取所有")]
        Task<List<SystemInfoEntity>> GetAll();

        /// <summary>
        /// 通过系统key获取系统信息
        /// </summary>
        /// <param name="systemKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "通过系统key获取系统信息")]
        Task<SystemInfoEntity> GetBySystemKey(string systemKey);
        
        /// <summary>
        /// 通过角色Id和系统Id获取所有的模块菜单和权限
        /// </summary>
        /// <param name="systemId"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "通过角色Id和系统Id获取所有的模块菜单和权限")]
        Task<List<PermissionListDto>> GetBySystemId(int systemId, Guid roleId);

        /// <summary>
        /// 获取当前登录用户某个系统的所有权限
        /// </summary>
        /// <param name="systemId"></param>
        /// <param name="roleId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "获取当前登录用户某个系统的所有权限")]
        Task<List<PermissionListDto>> GetDoraAuthedBySystemId(int systemId, Guid roleId, Guid userId);
        
        /// <summary>
        /// 获取用户用权限的系统的模块菜单
        /// </summary>
        /// <param name="systemId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "获取用户用权限的系统的模块菜单")]
        [Command(Strategy = StrategyType.Injection, Injection = @"return GetAuthedMenuList;")]
        Task<List<PermissionListDto>> GetAuthedMenuList(Guid userId, int systemId);
        
        /// <summary>
        /// 获取系统所有的模块菜单
        /// </summary>
        /// <param name="systemId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "获取系统所有的模块菜单")]
        [Command(Strategy = StrategyType.Injection, Injection = @"return GetAllMenu;")]
        Task<List<PermissionListDto>> GetAllMenu(int systemId);

        /// <summary>
        /// 导入系统列表
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-05", Director = "TTTan", Name = "导入系统列表")]
        Task<int> ImportList(List<SystemInfoEntity> list);
        
        ///// <summary>
        ///// 获取用户用权限的系统
        ///// </summary>
        ///// <param name="SystemId"></param>
        ///// <returns></returns>
        //Task<List<SystemInfoEntity>> GetAuthedList(Guid userId);

        /// <summary>
        /// 更新员工的系统菜单缓存
        /// </summary>
        /// <param name="systemKey"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<bool> DoraRefreshMenuCache(string systemKey, Guid userId);
        
    }
}
